public class Solution {
    public String getHint(String secret, String guess) {
        int b = 0, c = 0;
        StringBuilder sbs = new StringBuilder(secret);
        StringBuilder sbg = new StringBuilder(guess);

        int i=0;
        while(i < sbs.length()) {
            if(sbs.charAt(i) == sbg.charAt(i)) {
                b++;
                sbs.deleteCharAt(i);
                sbg.deleteCharAt(i);
            } else {
                i++;
            }
        }
        for(i = 0; i < sbs.length(); i++) {
            for(int j = 0; j < sbg.length(); j++) {
                if(sbs.charAt(i) == sbg.charAt(j)) {
                    c++;
                    sbg.deleteCharAt(j);
                    break;
                }
            }
        }
        return String.valueOf(b) + "A" + String.valueOf(c) + "B";
    }
}